import 'package:emby/pages/index.dart';
import 'package:emby/model/user.dart';
import 'package:emby/pages/search/search.dart';
import 'package:emby/pages/user/user.dart';
import 'package:emby/pages/video/video.dart';
import 'package:emby/widget/tab.dart';
import 'package:flutter/material.dart';

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int _currentIndex = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: IndexedStack(
        children: <Widget>[
          IndexPage(),
          Video(),
          Search(),
          UserPage(),
        ],
        index: _currentIndex,
      ),
      bottomNavigationBar: Container(
        decoration: BoxDecoration(
          color: Colors.white,
          border: Border(
            top: BorderSide(color: Colors.black12, width: 0.4),
          ),
        ),
        child: SafeArea(
          child: Row(
            children: <Widget>[
              TabItem(
                title: "首页",
                icon: "dashboard",
                selected: _currentIndex == 0,
                onTap: () {
                  setState(() {
                    _currentIndex = 0;
                  });
                },
              ),
              TabItem(
                title: "视频",
                icon: "movie",
                selected: _currentIndex == 1,
                onTap: () {
                  setState(() {
                    _currentIndex = 1;
                  });
                },
              ),
              TabItem(
                title: "搜索",
                icon: "search",
                selected: _currentIndex == 2,
                onTap: () {
                  setState(() {
                    _currentIndex = 2;
                  });
                },
              ),
              TabItem(
                title: "我的",
                icon: "user",
                selected: _currentIndex == 3,
                onTap: () {
                  setState(() {
                    _currentIndex = 3;
                  });
                },
              ),
            ],
          ),
        ),
      ),
    );
  }
}
